package com.zhouyu.aspect;

import com.zhouyu.service.UserInterface;
import com.zhouyu.service.UserServiceImplement;
import com.zhouyu.service.UserServiceInterface;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ZhouyuAspect {

	////会被解析成DeclareParentsAdvisor类型
	//@DeclareParents(value = "com.zhouyu.service.UserService", defaultImpl = UserServiceImplement.class)
	//private UserServiceInterface userServiceInterface;


	@Pointcut(value = "execution(public void com.zhouyu.service.UserService.test())")
	public void a(){

	}

	///**
	// *  JoinPoint:当前正在被代理的那个方法
	// *
	// * @param joinPoint
	// */
	//@Before(value = "a()")
	//public void zhouyuBefore(JoinPoint joinPoint) {
	//	//获取被代理对象
	//	Object target = joinPoint.getTarget();
	//	System.out.println(target.getClass());
	//	System.out.println("zhouyuBefore");
	//}


	@Before(value = "execution(public void com.zhouyu.service.UserService.b(..)) && args(a, b)", argNames = "a, b")
	public void zhouyuBefore(String a, String b) {
		System.out.println(a);
		System.out.println(b);
		System.out.println("zhouyuBefore");
	}

}
